home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
292_03
/
mond09.asm
< prev
next >
Wrap
Assembly Source File
|
1990-07-16
|
55KB
|
2,290 lines
.title MONDEB - 09
; *********************************************************
; * *
; * MONDEB - 09 - a monitor/debugger *
; * for the 6809 microprocessor *
; * *
; *********************************************************
;
; author: Don Peters (6800 version)
; date: April 1977
;
; modified for the 6809
; by: Alan R. Baldwin
; date: Nov 1988
;
; This 6809 monitor/debugger does not use the
; direct page addressing mode. Thus the user
; program has complete control of the page
; assignment and may use the monitor routines
; without concern for variable locations.
;
; To add user functions to MONDEB - 09
;
; 1) add your commands to the end of command list #1
; 2) add the command entry points to the jump table
; 3) append any local command lists after MONDEB's
; 4) provide an external initialization routine to
; set up the console (and/or alternate)
; ports and any other start up processing.
; MONDEB will call 'userinit' if inituser = 1.
;
.module mond09
standalone = 0 ; standalone flag indicating the
; vectors and associated code are
; to be included during assembly
inituser = 0 ; call 'userinit' flag indicating
; a user startup routine will be
; called during intialization
.page
.sbttl MONDEB - 09 working variables
.radix d
.if standalone
.area WORKPG (REL,CON)
.else
.area WORKPG (ABS,OVR)
.endif
.setdp 0
workpg: .blkb 256-(endpg-mstack)
; main stack storage
mstack: .blkb 12 ; stack storage for rti instruction
ttybuf: .blkb 72 ; start of input line buffer
ttyend: .blkb 1 ; end of input line buffer
bufbeg: .blkb 2 ; input line start of buffer
bufend: .blkb 2 ; input line end of buffer
comadr: .blkb 2 ; address of beginning of command lists
synptr: .blkb 2 ; input line character pointer for good syntax
linptr: .blkb 2 ; input line character pointer (content =>
; content of synptr)
bolflg: .blkb 1 ; "beginning of line flg"
delim: .blkb 1 ; characters permitted as valid command/modifier
; delimiter
ibcode: .blkb 1 ; input base (1=hex, 2=dec, 3=oct)
dbcode: .blkb 1 ; display base (1=hex, 2=dec, 3=oct, 4=bin)
dbnbr: .blkb 1 ; display base number (e.g., 16,10,8, or 2)
nbrhi: .blkb 1 ; most significant byte of scanned number
nbrlo: .blkb 1 ; least significant byte of scanned number
ranglo: .blkb 2 ; range lower limit picked up by gtrang
ranghi: .blkb 2 ; range upper limit picked up by gtrang
verfrm: .blkb 2 ; beginning address of range to verify
verto: .blkb 2 ; ending address of range to checksum verify
chksum: .blkb 1 ; checksum of range given in the verify command
brkadr: .blkb 2 ; address of inserted breakpoint
brkins: .blkb 1 ; instruction which should be there normally
inpflg: .blkb 1 ; alternate input flag
outflg: .blkb 1 ; alternate output flag
outadr: .blkb 2 ; alternate address that the output chars go to
hdxflg: .blkb 1 ; half-duplex terminal flag (if non-zero, no echo)
cplcnt: .blkb 1 ; "characters per line" count
cplmax: .blkb 1 ; "characters per line" maximum
; temporary (locally used) variables
temp1: .blkb 2 ; in: main
temp2: .blkb 2 ; in: main
temp3: .blkb 2 ; in: main
temp4: .blkb 2 ; in: main
temp5: .blkb 2 ; in: main
temp6: .blkb 2 ; in: main
nummat: .blkb 1 ; used in command
lisnum: .blkb 1 ; used in command
comnum: .blkb 1 ; used in command
lisptr: .blkb 2 ; used in command
decdig: .blkb 1 ; decimal digit being built
numbhi: .blkb 1 ; used by outnum
numblo: .blkb 1 ; used by outnum
nbr2x: .blkb 2 ; used by number
timcon: .blkb 2 ; delay time constant
bytect: .blkb 1 ; record byte count used in load command
cksm: .blkb 1 ; record checksum used in load command
conin: .blkb 2 ; address of console input routine
conout: .blkb 2 ; address of console output routine
altin: .blkb 2 ; address of alternate input routine
altout: .blkb 2 ; address of alternate output routine
.rsrvd: .blkb 2 ; reserved vector
.swi3: .blkb 2 ; swi3 vector
.swi2: .blkb 2 ; swi2 vector
.firq: .blkb 2 ; firq vector
.irq: .blkb 2 ; irq vector
.swi: .blkb 2 ; swi vector
.nmi: .blkb 2 ; nmi vector
spsave: .blkb 2 ; saved stack pointer
endpg:
; convenient equivalences for local variables
memadr = temp1 ; display, set, search, test
strnum = temp2 ; fndstr
eoschr = temp2+1 ; fndstr
; for "search" command
bytptr = temp2
nbytes = temp3
nbrmat = temp3+1
bytstr = temp4
; other constants
cr = 13 ; carriage return
lf = 10 ; line feed
.page
.sbttl MOND09 Startup
.if standalone
.area MONDEB (REL,CON)
reset: lds #mstack+12 ; load stack pointer
bsr mond09 ; stack pc and start mondeb
bra reset
.else
.area MONDEB (ABS,OVR)
.endif
mond09: pshs u,y,x,dp,b,a,cc ; pseudo swi
sts spsave ; save the pointer
orcc #0b01010000 ; hold irq and firq interrupts
lds #mstack ; initialize the stack pointer
jsr inital ; initialize variables
jsr docrlf ; advance to a clean line
ldx #msghed ; get address of header
jsr outstr ; type it
ldx #ttybuf-1 ; get address of terminal input buffer
stx bufbeg ; save it
ldx #ttyend ; define end of input buffer
stx bufend ; 72 char capacity, incl cr
lda #3 ; delimiter class definition
sta delim ; space or comma (code 3)
bra promp1
; prepare to get a new command
prompt: jsr docrlf ; type cr-lf
inc bolflg ; set 'beginning of line' flag
ldx synptr ; point to current character
lda ,x ; get it
cmpa #'; ; semicolon?
beq getcmd ; continue scan if it is,
; skipping the prompt
promp1: ldx #msgprm ; type prompt
jsr outstr
jsr getlin ; get line of input
cmpb #3 ; abort line on a control-c
beq prompt
ldx bufbeg ; set syntax scanning pointer
stx synptr ; to beginning of buffer/line
lda 1,x ; get first char
jsr tsteol ; reprompt on an empty line
beq prompt ; (first char = cr,lf,or ;)
.page
.sbttl Get Command
getcmd: lda #1 ; use list 1 when matching
jsr comand ; now go for a match
beq prompt ; reprompt if just a cr was typed
bgt jmpcmd ; good command if positive
badsyn: ldx bufbeg ; get start of line
1$: cpx linptr ; space over to the error in syntax
beq 2$ ; at error ?
jsr outsp ; output a space
inx ; no, move on
bra 1$
; the 'extra' char '1' is compensated for by the prompt
; char on the preceeding line
2$: lda #'^ ; at error - get an up-arrow
jsr outchr ; print it
jsr docrlf
bra promp1 ; ignore any succeeding packed
; commands
; *******
; *there should be no more characters on the input line
; (except delimiters)
nomore: jsr skpdlm
bcs prompt ; if carry bit set, end of line
; (normal)
bra badsyn ; there is something there but shouldn't be
.page
.sbttl Command Dispatcher
; ******
; execute a computed 'goto' to the proper command
jmpcmd: asla ; multiply command by 2
ldx #1$-2
jmp [a,x] ; jump to designated command
1$: .word break
.word contin
.word compar
.word copy
.word displa
.word dbase
.word delay
.word dump
.word goto
.word help
.word ibase
.word load
.word reg
.word set
.word search
.word test
.word verify
.word cli
.word clf
.word sei
.word sef
.word xirq
.word xfirq
.word xnmi
.word xrsrvd
.word xswi
.word xswi2
.word xswi3
.page
.sbttl REG - display registers
reg: ; print stack stored swi data
disreg: ldx spsave ; get saved stack pointer
clr comnum ; start at beginning of the
; register name list
bsr 1$ ; type condition codes
bsr 1$ ; type acca
bsr 1$ ; type accb
bsr 1$ ; type dp
jsr docrlf ; advance to a clean line
bsr 2$ ; type index reg x
bsr 2$ ; type index reg y
bsr 2$ ; type index reg u
jsr docrlf ; advance to a clean line
leax -9,x ; back to d
bsr 2$ ; type d
leax 7,x ; back to pc
bsr 2$ ; type program counter
; type the stack pointer location
bsr 3$ ; type stack pointer id
ldx #spsave
jsr out2by ; type the value
jmp nomore
; output content of a 1 byte register
1$: bsr 3$
jsr out1by
inx
rts
; output content of a 2 byte register
2$: bsr 3$
jsr ou